﻿<UserControl x:Class="TreeViewEx.SimpleSample.ColorPicker"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"  x:Name="this"
        d:DesignHeight="300" d:DesignWidth="300" Background="White">
    <DockPanel>
        <Border BorderBrush="Black" BorderThickness="1">
            <DockPanel>
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
                    <Label Margin="2">SelectedColor:</Label>
                    <Border CornerRadius="2" Background="{Binding SelectedColor, ElementName=this}" Width="20"
                            Height="20" Margin="2"/>
                </StackPanel>
                <StackPanel DockPanel.Dock="Bottom">
                    <Button HorizontalAlignment="Right" Click="Button_Click" Margin="2">Ok</Button>
                </StackPanel>
                <ItemsControl ItemsSource="{Binding Colors,ElementName=this}" DockPanel.Dock="Top" Margin="2">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border CornerRadius="2" Background="{Binding}" DataContext="{Binding}" Width="20" Height="20" MouseLeftButtonUp="Border_MouseLeftButtonUp" Margin="2" 
                                    BorderBrush="Black" BorderThickness="1"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </DockPanel>
        </Border>
    </DockPanel>
</UserControl>
